import { defineStore } from "pinia"
import { reqHospitalDetail, reqHospitalDeparment } from '@/api/hos';
import type { DetailState } from "./type"
import type { HospitalDetailData, DeparmentResponseData, HosPitalDetail } from '@/api/hos/type'

export default defineStore("Detail", {
    state: (): DetailState => ({
        hospitalInfo: {} as HosPitalDetail,
        deparmentArr: []
    }),
    actions: {
        async getHospital(hoscode: string) {
            let res: HospitalDetailData = await reqHospitalDetail(hoscode);
            if (res.code == 200) {
                this.hospitalInfo = res.data
            }
        },

        //获取某一个医院科室的数据
        async getDeparment(hoscode: string) {
            let result: DeparmentResponseData = await reqHospitalDeparment(hoscode);
            if (result.code == 200) {
                this.deparmentArr = result.data;
            }
        }
    },
    getters: {

    }
})